﻿Public Class CDiff_FileHash_ByName
	'Data
	Public SourceOnly As List(Of String)
	Public TargetOnly As List(Of String)
	Public Matching As List(Of String)
	Public Changed As Dictionary(Of String, CDiff_Guid)

	Public ReadOnly Property ChangedNames As List(Of String)
		Get
			Return New List(Of String)(Changed.Keys)
		End Get
	End Property


	Public Sub New()
		SourceOnly = New List(Of String)
		TargetOnly = New List(Of String)
		Matching = New List(Of String)
		Changed = New Dictionary(Of String, CDiff_Guid)
	End Sub

	Public Sub New(source As CFolderHash, target As CFolderHash)
		Dim d As CDiff_String = CDiffLogic.Diff(source.Names, target.Names)
		Me.SourceOnly = d.SourceOnly
		Me.TargetOnly = d.TargetOnly
		Me.Matching = d.Matching

		Me.Changed = New Dictionary(Of String, CDiff_Guid)

		For Each i As String In Me.Matching
			'File names with same content
			Dim src As List(Of Guid) = source.GetFiles(i)
			Dim tar As List(Of Guid) = target.GetFiles(i)
			Dim diff As CDiff_Guid = CDiffLogic.Diff(src, tar)
			If diff.SourceOnly.Count + diff.TargetOnly.Count > 0 Then
				Me.Changed.Add(i, diff)
			End If
		Next
	End Sub

End Class
